Given a tank with capacity C liters which is completely filled in starting. Everyday tank is filled with l liters of water and in the case of overflow extra water is thrown out. Now on i-th day i liters of water is taken out for drinking. We need to find out the day at which tank will become empty the first time....
Given positive integers k, a and b we need to print last k digits of a^b ie.. pow(a, b)....
Given a sorted array in which all elements appear twice (one after one) and one element appears only once. Find that element in O(log n) complexity....
Given a 2D matrix consisting of positive integers, the task is to find the minimum number of steps required to reach the end(leftmost-bottom cell) of the matrix. If we are at cell (i, j) we can go to cells (i, j+arr[i][j]) or (i+arr[i][j], j). We can not go out of bounds. If no path exists, print -1....
Problem Statement: Write a function to find if a given integer x appears more than n/2 times in a sorted array of n integers....
Given an array arr[], the task is to count the number of pairs (arr[i], arr[j]) on the right of every element with any custom comparator....
Binary search is a popular method of searching in a sorted array or list. It simply divides the list into two halves and discards the half which has zero probability of having the key. On dividing, we check the midpoint for the key and use the lower half if the key is less than the midpoint and the upper half if the key is greater than the midpoint. Binary search has a time complexity of O(log(n)). Binary search can also be implemented using multi-threading where we utilize the cores of the processor by providing each thread a portion of the list to search for the key. The number of threads depends upon the number of cores your processor has and it’s better to create one thread for each core. Examples:...
Given an array arr[] consisting of N integers, the task is to find the array K[] of minimum possible length such that after performing multiple mirror operations on K[], the given array arr[] can be obtained....
Given an array arr[] of N integers, the task is to perform the following two queries:...
Given an array arr[] of N integers, the task is to perform the following two queries:...
Given an array of size N, initially consists of zeroes only. The task is to apply the given operation q times and find the number of different numbers in the array except for zeroes. Operation Format: update(l, r, x):: update a[i] = x for all (l <= i <= r)....
Given a sorted array arr[], and a set Q having M queries, where each query has values X and Y, the task is to find the sum of all integers less than X and greater than Y present in the array. Note: X and Y may or may not be present in the array....